package org.gap.service;

import java.util.List;
import java.util.Set;

import org.gap.domain.CaractPM;
import org.gap.domain.Tiers;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/GAP_v2-security-context.xml",
		"file:./resources/GAP_v2-service-context.xml",
		"file:./resources/GAP_v2-dao-context.xml",
		"file:./resources/GAP_v2-web-context.xml" })
@Transactional
public class CaractPMServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected CaractPMService service;

	/**
	 * Instantiates a new CaractPMServiceTest.
	 *
	 */
	public CaractPMServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Return a count of all CaractPM entity
	 * 
	 */
	@Test
	public void countCaractPMs() {
		Integer response = null;
		response = service.countCaractPMs();
		// TODO: JUnit - Add assertions to test outputs of operation: countCaractPMs
	}

	/**
	 * Operation Unit Test
	 * Save an existing Tiers entity
	 * 
	 */
	@Test
	public void saveCaractPMTiers() {
		// TODO: JUnit - Populate test inputs for operation: saveCaractPMTiers 
		Integer cpmTiers = 0;
		Tiers related_tiers = new org.gap.domain.Tiers();
		CaractPM response = null;
		response = service.saveCaractPMTiers(cpmTiers, related_tiers);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCaractPMTiers
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findCaractPMByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findCaractPMByPrimaryKey 
		Integer cpmTiers_1 = 0;
		CaractPM response = null;
		response = service.findCaractPMByPrimaryKey(cpmTiers_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findCaractPMByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Load an existing CaractPM entity
	 * 
	 */
	@Test
	public void loadCaractPMs() {
		Set<CaractPM> response = null;
		response = service.loadCaractPMs();
		// TODO: JUnit - Add assertions to test outputs of operation: loadCaractPMs
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Tiers entity
	 * 
	 */
	@Test
	public void deleteCaractPMTiers() {
		// TODO: JUnit - Populate test inputs for operation: deleteCaractPMTiers 
		Integer caractpm_cpmTiers = 0;
		Integer related_tiers_tieTiers = 0;
		CaractPM response = null;
		response = service.deleteCaractPMTiers(caractpm_cpmTiers, related_tiers_tieTiers);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCaractPMTiers
	}

	/**
	 * Operation Unit Test
	 * Delete an existing CaractPM entity
	 * 
	 */
	@Test
	public void deleteCaractPM() {
		// TODO: JUnit - Populate test inputs for operation: deleteCaractPM 
		CaractPM caractpm = new org.gap.domain.CaractPM();
		service.deleteCaractPM(caractpm);
	}

	/**
	 * Operation Unit Test
	 * Return all CaractPM entity
	 * 
	 */
	@Test
	public void findAllCaractPMs() {
		// TODO: JUnit - Populate test inputs for operation: findAllCaractPMs 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<CaractPM> response = null;
		response = service.findAllCaractPMs(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllCaractPMs
	}

	/**
	 * Operation Unit Test
	 * Save an existing CaractPM entity
	 * 
	 */
	@Test
	public void saveCaractPM() {
		// TODO: JUnit - Populate test inputs for operation: saveCaractPM 
		CaractPM caractpm_1 = new org.gap.domain.CaractPM();
		service.saveCaractPM(caractpm_1);
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
